package com.verify.repository;

import com.baomidou.mybatisplus.extension.service.IService;
import com.verify.data.domain.SecondaryUnit;
import com.verify.mapper.SecondaryUnitMapper;
import com.verify.repository.base.BaseRepository;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class SecondaryUnitRepository extends BaseRepository<SecondaryUnitMapper, SecondaryUnit>
        implements IService<SecondaryUnit> {
    public SecondaryUnit getByCode(String unitCode) {
        return getOne(baseQuery().eq(SecondaryUnit::getUnitCode, unitCode));
    }

    public SecondaryUnit getByChildCode(String orgCode) {
        return getOne(baseQuery().likeRight(SecondaryUnit::getUnitCode, orgCode.substring(0, 2)));
    }
}
